package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Chat;
import cn.wolfcode.trip.base.mapper.ChatMapper;
import cn.wolfcode.trip.base.service.IChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class ChatServiceImpl implements IChatService{
    @Autowired
    private ChatMapper chatMapper;
    /*
    * 查询聊天记录
    *
    * */
    @Override
    public List<Chat> listForChatHistory(Long sendId, Long receiveId) {
        return chatMapper.listForChatHistory(sendId,receiveId);
    }
    /*
    * 添加聊天记录
    * */
    @Override
    public void save(Chat chat) {
        chat.setTime(new Date());
        chat.setState(false);
         chatMapper.insert(chat);
    }
    /*
    * 查未读状态
    * */
    @Override
    public List<Chat> listState(Long receiveId) {
        return chatMapper.listState(receiveId);
    }

    @Override
    public void updateState(Long receiveId) {
        chatMapper.updateState(receiveId);
    }

    @Override
    public Integer listStateNum(Long receiveId) {
        return chatMapper.listStateNum(receiveId);
    }
}
